package com.kehutong.contact.admin;

import com.kehutong.common.util.Token;
import com.kehutong.contact.entity.ContactComment;
import com.kehutong.contact.entity.ContactDynamics;
import com.kehutong.contact.service.ContactCommentService;
import com.kehutong.contact.service.ContactDynamicsService;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.Pool;
import org.coraframework.orm.jdbc.JdbcSession;
import org.coraframework.orm.jdbc.Page;

/**
 * @author liujinwang
 * description: 评论
 */
@MvcAction
@ReqMapping("/admin/crm/contact/comment")
public class CommentController {

    @Inject
    private JdbcSession jdbcSession;

    @Inject
    private ContactCommentService contactCommentService;

    /**
     * 评论列表
     */
    @ReqMapping("/page")
    public Object page(JSONObject jsonObject) throws Exception{
        return contactCommentService.page(jsonObject);
    }

    /**
     * 新增评论
     */
    @Bean(newInstance = true, copy = true)
    @ReqMapping("/save")
    public Object save(Token token,ContactComment comment) throws Exception{
        comment.setUserNo(token.getUuid());
        comment.setUserName(token.getName());
        return contactCommentService.save(comment);
    }

    /**
     * 删除评论
     */
    @ReqMapping("/delete")
    public Object delete(ContactComment comment) throws Exception{
        return contactCommentService.delete(comment);

    }


}
